<?php
switch($action)
{
	case 'load':
		if($value)
		{
			$str = '<select onchange="$(\'#'.$value.'\').val(this.value);this.disabled=true;area_load(this.value);"><option value="0">'.$LANG['please_select'].'</option>';
			$options = '';
			foreach($AREA as $i=>$v)
			{
				if($v['parentid'] == $id)  $options .= '<option value="'.$i.'">'.$v['name'].'</option>';
			}
			if(empty($options)) exit;
			$str .= $options.'</select>';
		
		}
		else
		{
			$str = '<select onchange="$(\'#areaid\').val(this.value);this.disabled=true;areaid_load(this.value);"><option value="0">'.$LANG['please_select'].'</option>';
			$options = '';
			foreach($AREA as $i=>$v)
			{
				if($v['parentid'] == $id)  $options .= '<option value="'.$i.'">'.$v['name'].'</option>';
			}
			if(empty($options)) exit;
			$str .= $options.'</select>';
		
		}
		echo $str;
	break;
	
	// 
	case 'ajax':
		$data = $db->get_one("select `name`,`intro` from ".DB_PRE."area where `dir` = 'shanghai'");
		$return = $data['intro'] ? $data['intro'] : $data['name'];
		echo($return."<a href=\"".url("?module=area&prefix=$prefix")."\">进入小组</a>");
	break;
	
	default:
		/*if($name){
			echo $name;
		}*/
		if($areaid){
			$areaid = intval($areaid);
		}
		else if($dir){
			$data = $db->get_one("select `areaid` from ".DB_PRE."area where `dir` = '$dir'");
			$areaid = intval($data['areaid']);
			unset($data);
		}
		
		if($areaid) {
			if(!isset($AREA[$areaid])) showmessage('访问的地区不存在！');
		
			/*$catid = intval($catid);
			if(!isset($CATEGORY[$catid])) showmessage('访问的栏目不存在！');
			$C = cache_read('category_'.$catid.'.php');*/
			
			$A = cache_read('area_'.$areaid.'.php');
			extract($A);
			$head['title'] = $name;
			$head['keywords'] = $meta_keywords;
			$head['description'] = $meta_description;
			
			$page = max(intval($page), 1);
			
			
			/*$catlist = submodelcat($C['modelid']);
			unset($catlist[$catid]);
			
			$arrchildid = $CATEGORY[$catid]['arrchildid'];
			
			if($child)
			{
				$areas = subarea($areaid);
				$arr_areaid = $AREA[$areaid]['arrchildid'];
				$template = $template ? $template : 'area.html';
			}
			else
			{
				$template = 'area_list.html';
			}
			include template($template,'area');*/
			
			include template('area.html','area');
		}
		else{
			include template('index.html','area');
			
		}

	break;
}
?>